package com.dc.util;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.dc.exceptions.BizException;
import com.dc.vo.SysUserVO;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class UserUtil {

    public static String getUserId() {
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = requestAttributes.getRequest();
        String userIdStr = request.getHeader("Authorization-UserId");
        if (StrUtil.isBlank(userIdStr)) {
            throw new BizException("获取用户信息失败");
        } else {
            return userIdStr;
        }
    }




}
